import Vue from 'vue';
import VueRouter from 'vue-router';
import Home from '@/views/home/home.vue';
import Category from '@/views/category/category.vue';
import Cart from '@/views/cart/cart.vue';
import My from '@/views/my/my.vue';

Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    children: [
      {
        path: 'list',
        component: () => import('../views/home/children/list.vue')
      },
      {
        path: 'grab',
        component: () => import('../views/home/children/grab.vue')
      }
    ]
  },
  {
    path: '/category',
    name: 'Category',
    component: Category
  },
  {
    path: '/cart',
    name: 'Cart',
    component: Cart
  },
  {
    path: '/my',
    name: 'My',
    component: My
  },
  {
    path: '/detail/:id',
    name: 'Detail',
    component: () => import('@/views/detail/detail.vue')
  },
  {
    path: '/demo',
    name: 'Demo',
    component: () => import('@/views/demo/demo.vue')
  },
  {
    path: '/order/submit',
    name: 'submit',
    component: () => import('../views/order/submit.vue'),
  },
  {
    path: '/order',
    name: 'Order',
    component: () => import('../views/order/order.vue'),
  },
  {
    path: '/order/detail/:id',
    name: 'orderDetail',
    component: () => import('../views/order/detail.vue')
  },
  {
    path: '/address/address',
    name: 'address',
    component: () => import('../views/address/address.vue')
  },
  {
    path: '/address/add',
    name: 'addressAdd',
    component: () => import('../views/address/add.vue')
  },
  {
    path: '/my/set',
    name: 'Set',
    component: () => import('../views/set/set.vue')
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/login/login.vue')
  }
];

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
});

export default router;